package luanluan.utils 
{
	import com.greensock.TweenLite;
	import flash.utils.Dictionary;
	/**
	 * ...
	 * @author luanluan
	 */
	public class TimeUtils 
	{
		private static var TweenDic:Dictionary = new Dictionary();
		
		/**
		 * 一定时间后执行某动作
		 * @param	duration
		 * @param	callBackFunction
		 */
		static public function add(duration:Number , callBackFunc:Function ,...params):void
		{
			if (TweenDic[callBackFunc] != null)
				TweenDic[callBackFunc].kill();
			TweenDic[callBackFunc] = TweenLite.to(TimeUtils , duration, { onComplete:complete , onCompleteParams:[callBackFunc , params] } );
		}
		
		static public function remove(callBackFunc:Function):void
		{
			if (TweenDic[callBackFunc] != null)
			{
				TweenDic[callBackFunc].kill();
				delete TweenDic[callBackFunc];
			}
		}
		
		private static function complete(callBackFunc:Function, params:Array):void
		{
			delete TweenDic[callBackFunc]
			callBackFunc.apply(null, params);
		}
		
	}

}